<template>
  <div>
    <div class="swiper">
      <van-swipe
        class="my-swipe"
        style="height: 150px"
        :autoplay="3000"
        indicator-color="white"
      >
        <van-swipe-item v-for="item in result" @click="turnother(item.goodsid)">
          <img :src="item.goodscover" alt="" />
        </van-swipe-item>
      </van-swipe>
    </div>
  </div>
</template>
<style scoped lang="scss">
.swiper{
  margin-top: 20px;
}
.my-swipe .van-swipe-item {
  color: #fff;
  font-size: 20px;
  line-height: 150px;
  text-align: center;
  background-color: #39a9ed;
  img {
    width: 100%;
    height: 150px;
    // background-size: cover;
  }
}
</style>
<script>
import axios from "axios";
// import { defineComponent } from '@vue/composition-api'
import { mapState } from "vuex";
export default {
  data() {
    return {};
  },
  data() {
    return {
      result: [],
    };
  },
  computed: {
    ...mapState(["user"]),
  },
  methods: {
    turnother(goodsid) {
      this.$router.push("productdetail");
      localStorage.setItem("goodsid", goodsid);
    },
  },
  created() {
    axios({
      method: "get",
      url: "http://192.168.35.11:3005/goods",
    }).then((response) => {
      console.log(response.data.result);
      this.result = [...response.data.result];
      console.log(this.result);
    });
  },
};
</script>
